{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "# 聚类分析\n",
    "实验一组算法，不少于4个，至少包含一个基于划分的、一个基于层次的、一个基于密度的，具体的算法自行选择。对给定的数据集进行聚类分析。\n",
    "实验数据集：控制图时间序列数据集、Epileptic Seizure Recognition Data。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The autoreload extension is already loaded. To reload it, use:\n",
      "  %reload_ext autoreload\n"
     ]
    }
   ],
   "source": [
    "# 初始化\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "import BinaryKMeans as BKM\n",
    "import KMeans as KM\n",
    "import AGNES as AS\n",
    "import DBSCAN as DN\n",
    "# 将图和数据内联在notebook里\n",
    "%matplotlib inline\n",
    "%load_ext autoreload\n",
    "%autoreload 2\n",
    "# 颜色列表\n",
    "colValue = ['r', 'b', 'y','k']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 生成模拟数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "# 数据集：每三个是一组分别是西瓜的编号，密度，含糖量\n",
    "data = '''\n",
    "1,0.697,0.46,2,0.774,0.376,3,0.634,0.264,4,0.608,0.318,5,0.556,0.215,\n",
    "6,0.403,0.237,7,0.481,0.149,8,0.437,0.211,9,0.666,0.091,10,0.243,0.267,\n",
    "11,0.245,0.057,12,0.343,0.099,13,0.639,0.161,14,0.657,0.198,15,0.36,0.37,\n",
    "16,0.593,0.042,17,0.719,0.103,18,0.359,0.188,19,0.339,0.241,20,0.282,0.257,\n",
    "21,0.748,0.232,22,0.714,0.346,23,0.483,0.312,24,0.478,0.437,25,0.525,0.369,\n",
    "26,0.751,0.489,27,0.532,0.472,28,0.473,0.376,29,0.725,0.445,30,0.446,0.459\n",
    "'''\n",
    "a = data.split(',')\n",
    "dataset = np.array([(float(a[i]),float(a[i+1])) for i in range(1,len(a)-1,3)])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### K均值法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "<Figure size 432x288 with 1 Axes>",
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXsAAAD4CAYAAAANbUbJAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAXqUlEQVR4nO3df4wcd3nH8fcTXywL6nBt7BRyZ+MLFxLHEUT2xWmkiJBKUYJbcIIj4TQqAkeKQgndHqJKVKloJVQp/IGcUxNqWRAh8UesqkBwS+JUImqoQit8gQSwi8vVDngvf2CcHmBEGp/v6R+7e7e33rud/TE7853v5yWt7Lmdnf3Ozcxz33nmO8+YuyMiIsV2SdYNEBGR9CnYi4hEQMFeRCQCCvYiIhFQsBcRicBQVl+8YcMG37JlS1ZfLyISpJdeeumX7r6x089lFuy3bNnC9PR0Vl8vIhIkM/tZN59LlMYxszvN7ISZzZjZIy3ef7+Z/crMXq69PttNY0REJB1te/ZmtgZ4ArgdqABHzeywux9vmvXf3f1PU2ijiIj0KEnPficw4+4n3f1N4BCwO91miYhIPyXJ2Y8ApxumK8BNLea72cxeAV4DPuPux5pnMLMHgAcANm/efNECzp8/T6VS4Y033kjQrOysW7eO0dFRLr300qybIiKSSJJgby1+1lxQ5/vAO939nJntAp4Grr7oQ+4HgYMAExMTFxXlqVQqrF+/ni1btmDW6muz5+6cPXuWSqXC2NhY1s0RkYy4+7I41TydN0nSOBVgU8P0KNXe+yJ3/7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uAn2Td7n6vY8N8zwPPAPdk3e4UtuP7gX/Juq0DWM9h4DiwuTZ9Rdbt7vc6Ns3/QeD5rNudwnb8G+Dztf9vBF4H1q62XPXsV7cTmHH3k+7+JnAI2N04g7uf89pvHHgrENoV77brWPMp4GvALwbZuD5Juo6hS7KefwZ83d1/DuDuoW3PTrflvcBTA2lZ/yRZRwfWm5lR7XC+DsyvtlAF+9WNAKcbpiu1ny1jZneb2U+AbwH7BtS2fmm7jmY2AtwNHBhgu/op0XYEbq6dFj9rZtsG07S+SrKe7wZ+38z+zcxeMrOPDqx1/ZF0W2JmbwHupNpJCUmSdXwc2Aq8BvwIKLn7wmoLVbBfXatHP1zUc3f3b7j7tcBdwOfSblSfJVnHx4CH3f1C+s1JRZJ1/D7wTnd/L/D3wNNpNyoFSdZzCNgB/AlwB/C3ZvbutBvWR4mOyZoPAi+6++spticNSdbxDuBl4ErgBuBxM7tstYUq2K+uAmxqmB6l+pe0JXf/DvAuM9uQdsP6KMk6TgCHzOxV4B7gi2Z210Ba1x9t19Hdf+3u52r/fwa4NLDtCMm2ZQU44u6/dfdfAt8B3jug9vVDJ8fkXsJL4UCydfw41XScu/sMcAq4dtWlZn0xIs8vqr2gk8AYSxdKtjXNM87SBdrtwGx9OoRXknVsmv8rhHeBNsl2fHvDdtwJ/Dyk7djBem4Fvl2b9y3Aj4Hrs257P9exNt/bqOax35p1m1Pajv8AlGv//8Na3Nmw2nIzq3oZAnefN7OHgOeoXiF/0t2PmdmDtfcPAHuAj5rZeeB3wEe8tgVCkHAdg5ZwHe8BPmFm81S3496QtiMkW093/y8zOwL8EFgAvuTuP86u1Z3pYH+9G/hXd/9tRk3tWsJ1/BzwFTP7EdW0z8NePVNbkcoliIhEQDl7EZEIKNiLiERAwV5EJAIK9iIiEVCwFxGJgIK9iEgEFOxFRCLw/x88iCLx+pZgAAAAAElFTkSuQmCC\n"
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 调用KMeans方法\n",
    "centroids, centIndxDist=KM.kMeans(dataset,3)\n",
    "idx=centIndxDist[:,0].astype(np.int32)\n",
    "# 画图\n",
    "for i in range(len(centroids)):\n",
    "    plt.scatter(dataset[np.nonzero(idx==i),0],dataset[np.nonzero(idx==i),1],\n",
    "                marker='x', c=colValue[i], label=i)\n",
    "plt.legend(loc='upper left')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "### 二分K均值法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "<Figure size 432x288 with 1 Axes>",
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXsAAAD4CAYAAAANbUbJAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAXqUlEQVR4nO3df4wcd3nH8fcTXywL6nBt7BRyZ+MLFxLHEUT2xWmkiJBKUYJbcIIj4TQqAkeKQgndHqJKVKloJVQp/IGcUxNqWRAh8UesqkBwS+JUImqoQit8gQSwi8vVDngvf2CcHmBEGp/v6R+7e7e33rud/TE7853v5yWt7Lmdnf3Ozcxz33nmO8+YuyMiIsV2SdYNEBGR9CnYi4hEQMFeRCQCCvYiIhFQsBcRicBQVl+8YcMG37JlS1ZfLyISpJdeeumX7r6x089lFuy3bNnC9PR0Vl8vIhIkM/tZN59LlMYxszvN7ISZzZjZIy3ef7+Z/crMXq69PttNY0REJB1te/ZmtgZ4ArgdqABHzeywux9vmvXf3f1PU2ijiIj0KEnPficw4+4n3f1N4BCwO91miYhIPyXJ2Y8ApxumK8BNLea72cxeAV4DPuPux5pnMLMHgAcANm/efNECzp8/T6VS4Y033kjQrOysW7eO0dFRLr300qybIiKSSJJ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IiEVCwFxGJgIK9iEgEFOxFRCLw/x88iCLx+pZgAAAAAElFTkSuQmCC\n"
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 调用二分KMeans方法\n",
    "centroids, centIndxDist=BKM.biKMeans(dataset,3)\n",
    "# 画图\n",
    "for i in range(len(centroids)):\n",
    "    plt.scatter(dataset[np.nonzero(idx==i),0],dataset[np.nonzero(idx==i),1],\n",
    "                marker='x', c=colValue[i], label=i)\n",
    "plt.legend(loc='upper left')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### AGNES"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "<Figure size 432x288 with 1 Axes>",
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXsAAAD4CAYAAAANbUbJAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAYyElEQVR4nO3db4xcV3nH8e9jbywL6rBt7DRk18YbNiSOI4jsjVOkCJNKUYJbcIIjYYiKwJGsUEJHi6gSVSoaCSGFF2izakItK4qQeBGrKv/c4jiVCIUqtMIbSIC4JGyzAc/kBcHpAkak8Xqevpi53juzs7t3Z+bOnXPv7yOt7Ls7O3OuZ+bnM8859xxzd0REJN/WZd0AERFJn8JeRKQAFPYiIgWgsBcRKQCFvYhIAQxl9cCbN2/27du3Z/XwIiJBeuaZZ37t7lvW+nuZhf327duZmZnJ6uFFRIJkZr/o5PcSlXHM7HYze8HMZs3sgTY/f6+Z/cbMnm18fbaTxoiISDpW7dmb2XrgEeBWoAKcMrPj7n665ab/4e5/mUIbRUSkS0l69nuAWXd/yd3fAI4B+9NtloiI9FKSmv0IcCZ2XAFuanO7d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ufv3gLeb2ea0G9ZDSc5xAjhmZi8DdwFfMrM7+tK63lj1HN39t+5+rvH3E8AlgT2PkOy5rAAn3f337v5r4HvAu/rUvl5Yy3vyIOGVcCDZOX6cejnO3X0WmAOuXfFesx6MGOQv6r2gl4AxFgdKdrbcZpzFAdpdQDU6DuEryTm23P7LhDdAm+R5vCL2PO4BfhnS87iG89wBfLtx2zcBPwWuz7rtvTzHxu3eQr2O/eas25zS8/iPQLnx9z9t5M7mle43s1UvQ+DuC2Z2H/Ak9RHyx9z9eTO7t/HzI8AB4KNmdh74A/AhbzwDIUh4jkFLeI53AZ8wswXqz+PBkJ5HSHae7v7fZnYS+DFQAx51959m1+q1WcPr9U7g39z99xk1tWMJz/FzwJfN7CfUyz73e/2T2rK0XIKISAGoZi8iUgAKexGRAlDYi4gUgMJeRKQAFPYiIgWgsBcRKQCFvYhIAfw/TIT4oCOzVAEAAAAASUVORK5CYII=\n"
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 调用AGNES方法\n",
    "C=AS.AGNES(dataset,3,'max')\n",
    "# 画图\n",
    "for i in range(len(C)):\n",
    "    Ci=np.array(C[i])\n",
    "    plt.scatter(Ci[:,0],Ci[:,1],\n",
    "                marker='x', c=colValue[i], label=i)\n",
    "plt.legend(loc='upper left')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "### DBSCAN"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "<Figure size 432x288 with 1 Axes>",
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXsAAAD4CAYAAAANbUbJAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXB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cAA4DvwPcCfwnM3vvsBuWoVR/k22/C/wPd//FENszDGmO8U7gFPBu4Gbgq2b2G5u9qYL95paAaxPbU7T+T9qTu38beI+Z7Rl2wzKU5hhngRNm9lPgXuDPzOzjI2ldNrY8Rnf/pbu/0f73c8BlgZ1HSHcul4AX3P1f3P3nwLeBgyNqXxa28zd5nPBSOJDuGP+AVjrO3X0BWARu2PRd8x6MKPKDVi/oNWCatYGSm7r2mWFtgPYQsBxvh/BIc4xd+3+d8AZo05zHaxLn8Rbgn0I6j9s4zgPA37b3/TXgx8D78257lsfY3u9KWnnsd+bd5iGdx/8K1Nr//s123Nmz2fvqhuObcPcVM3sYeJHWCPmT7v6ymT3Yfv1x4PeAT5rZJeBXwO97+wyEIOUxBi3lMd4L/KGZrdA6j8dDOo+Q7jjd/RUzewH4EdAE/tzdf5xfq7dnG9/Xe4D/5u7/klNT+5byGD8PfN3M/oFW2uez3rpS25DKJYiIlIBy9iIiJaBgLyJSAgr2IiIloGAvIlICCvYiIiWgYC8iUgIK9iIiJfD/AYs0vJtM2WGQAAAAAElFTkSuQmCC\n"
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 调用DBSCAN方法\n",
    "a=DN.DBSCAN(dataset,0.1,4)\n",
    "# 画图\n",
    "for i in range(np.min(a),np.max(a)):\n",
    "    plt.scatter(dataset[np.nonzero(idx==i),0],dataset[np.nonzero(idx==i),1],\n",
    "                marker='x', c=colValue[i+1], label=i)\n",
    "plt.legend(loc='upper left')\n",
    "plt.show()\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "PyCharm (Clustering)",
   "language": "python",
   "name": "pycharm-93ca9ab9"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}